<?php
namespace app\common\model;
use think\Model;
use think\Validate;
use app\common\controller\Tools;
use app\common\model\Enterprise;

class TempPhone extends Model
{
	protected $table = 'temp_phone';
	protected $pk = 'id';

	/**
	 * @todo 通过手机号获取一分钟内发送过的短信
	 * @param $phone
	 * @return bool
	 */
	public function checkSecondInByPhone($phone)
	{
		$res = TempPhone::where('phone',$phone)->where('create_time','>=',time()-60)->select();
		if ($res) {
			return false;
		}
		return true;
	}

	/**
	 * @todo 检测用户ip地址,每小时不超过10次
	 * @param $ip
	 * @return bool
	 */
	public function checkIpNoMoreTen($ip)
	{
		$res = TempPhone::where('ip',$ip)->where('create_time','>=',time()-60*60)->count();
		if ($res > 10) {
			return false;
		}
		return true;
	}
}